package com.miboxlabs.esecure.data;

import java.util.ArrayList;

import com.miboxlabs.esecure.R;
import com.miboxlabs.esecure.entity.Folder;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class FolderListAdapter extends BaseAdapter {

	private final Activity activity;
	private ArrayList<Folder> folderList;
	private static LayoutInflater inflater = null;

	public View mainView;
	public Context mycontext;

	public FolderListAdapter(Activity a, ArrayList<Folder> folderList) {
		activity = a;
		this.folderList = folderList;
		inflater = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mycontext = activity.getApplicationContext();

	}

	public int getCount() {
		return folderList.size();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public static class ViewHolder {	
		public TextView lblFolderNameInList;

	}

	public View getView(final int position, final View convertView,
			ViewGroup parent) {
		View vi = convertView;
		final ViewHolder holder;
		if (convertView == null) {
			vi = inflater.inflate(R.layout.folderlistitem, null);
			holder = new ViewHolder();

			holder.lblFolderNameInList = (TextView) vi
					.findViewById(R.id.lblFolderNameInList);

			vi.setTag(holder);
		} else
			holder = (ViewHolder) vi.getTag();
		
		String folderName=folderList.get(position).getName();
		
		holder.lblFolderNameInList.setText(folderName);
		return vi;
	}

}
